﻿using System;

namespace CacheNaga.Core
{
	public class CacheManagerBase
	{
		#region 缓存操作

		/// <summary>
		/// 无条件存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		public virtual void Set(string key, object value)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 无条件存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="absoluteExpiration">绝对过期时间</param>
		public virtual void Set(string key, object value, DateTime absoluteExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 无条件存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="absoluteExpiration">绝对过期时间</param>
		public virtual void Set(string key, object value, TimeSpan absoluteExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 无条件存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="slidingExpiration">滑动过期时间</param>
		public virtual void SetSlidingExpiration(string key, object value, DateTime slidingExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 无条件存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="slidingExpiration">滑动过期时间</param>
		public virtual void SetSlidingExpiration(string key, object value, TimeSpan slidingExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 如果缓存key不存在再存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		public virtual void Add(string key, object value)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 如果缓存key不存在再存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="absoluteExpiration">绝对过期时间</param>
		public virtual void Add(string key, object value, DateTime absoluteExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 如果缓存key不存在再存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="absoluteExpiration">绝对过期时间</param>
		public virtual void AddSlidingExpiration(string key, object value, TimeSpan absoluteExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 如果缓存key不存在再存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="slidingExpiration">滑动过期时间</param>
		public virtual void AddSlidingExpiration(string key, object value, DateTime slidingExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 如果缓存key不存在再存储
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="slidingExpiration">滑动过期时间</param>
		public virtual void Add(string key, object value, TimeSpan slidingExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 仅当缓存项存在时替换缓存,否则不做操作
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		public virtual void Replace(string key, object value)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 仅当缓存项存在时替换缓存,否则不做操作
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="absoluteExpiration">缓存过期时间</param>
		public virtual void Replace(string key, object value, DateTime absoluteExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 仅当缓存项存在时替换缓存,否则不做操作
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <param name="absoluteExpiration">缓存过期时间</param>
		public virtual void Replace(string key, object value, TimeSpan absoluteExpiration)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 根据key获取缓存项
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public virtual object Get(string key)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 删除缓存项
		/// </summary>
		/// <param name="key"></param>
		public virtual void Remove(string key)
		{
			throw new NotImplementedException();		
		}

		/// <summary>
		/// 检查是否包含缓存项
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public virtual bool Contains(string key)
		{
			throw new NotImplementedException();
		}

		#endregion
		
		#region 辅助方法

		/// <summary>
		/// 检查
		/// </summary>
		/// <param name="key"></param>
		protected void CheckKey(string key)
		{
			//空(null/empty)检查
			if (string.IsNullOrEmpty(key))
				throw new ArgumentNullException("key");
			//长度检查
			if(key.Length>250)
				throw new ArgumentException("Key的长度不能超过250个字符");
			//非法字符检查
			foreach (char c in key)
				if (c <= 32)
					throw new ArgumentException("key不能包含空格和控制性字符");
		}

		#endregion
	}
}
